#include <bits/stdc++.h>
#define double long double
#define int long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int, int> pi;
const int MOD=1000000007;
int gcd(int a, int b) {return (b==0? a: gcd(b, a%b));}
int lcm(int a, int b) {return a*b/gcd(a, b);}
void yes() {cout << "YES\n"; return;}
void no() {cout << "NO\n"; return;}
int to(string s){
int n=s.size();
int i=0;
while(i<n && s[i]=='0') i++;
int cnt=s[i]-'0';
for(i=i+1; i<s.size(); i++){
cnt*=s[i]-'0';
}
return cnt;
}
void solve() {
int n;
cin >> n;
vector<int> t1(n), t2(n);
for(int i=0; i<n; i++){
cin >> t1[i];
t2[i]=t1[i];
}
int cnt=0;
sort(t1.begin(), t1.end());
sort(t2.rbegin(), t2.rend());
for(int i=0; i<n; i++){
cnt+=t1[i]*t2[i];
cnt%=10007;
}
cout << cnt << "\n";
}
signed main() {
cin.tie(0)->sync_with_stdio(0);
srand(time(0));
int t=1;
// cin >> t;
//sieve(1e7);
while(t--){
solve();
}
}
1610A - Anti Light's Cell Guessing | 349B - Color the Fence |
144A - Arrival of the General | 1106A - Lunar New Year and Cross Counting |
58A - Chat room | 230A - Dragons |
200B - Drinks | 13A - Numbers |
129A - Cookies | 1367B - Even Array |
136A - Presents | 1450A - Avoid Trygub |
327A - Flipping Game | 411A - Password Check |
1520C - Not Adjacent Matrix | 1538B - Friends and Candies |
580A - Kefa and First Steps | 1038B - Non-Coprime Partition |
43A - Football | 50A - Domino piling |
479A - Expression | 1480A - Yet Another String Game |
1216C - White Sheet | 1648A - Weird Sum |
427A - Police Recruits | 535A - Tavas and Nafas |
581A - Vasya the Hipster | 1537B - Bad Boy |
1406B - Maximum Product | 507B - Amr and Pins |